package com.wtcrazy.controller;

import com.wtcrazy.service.IFilesService;
import com.wtcrazy.service.Impl.FilesServiceImpl;
import com.wtcrazy.utils.JsonResult;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("/Files")
public class FilesController {
    @Autowired
    private FilesServiceImpl filesService;

    @ApiOperation("【拦截】文件上传")
    @PostMapping("/upload")//【主要返回一个路径】
    public JsonResult upload(MultipartFile file, HttpServletRequest req) {//MultipartFile是SpringMVC提供简化上传操作的工具类
        return filesService.upload(file, req);
    }
}
